<?php 
function addModType1($mod_id)
{		
	$insert  = "INSERT INTO ".DB_PERFIX."mod_type_1 (`mod_id`, `max`, `cols`, `rows`)"; 
	$insert .= 'VALUES ('.$mod_id.', 0, 0, 0);';
	$result = mysql_query($insert);
	return $result;
}
function updateModType1($mod_id)
{		
	
	$insert  = 'UPDATE '.DB_PERFIX.'mod_type_1 '; 
	$insert .= 'SET max='.$_POST['max'].', cols='.$_POST['cols'].', rows='.$_POST['rows'].' , indexing='.$_POST['indexing'].' WHERE mod_id='.$mod_id.';';
	$result = mysql_query($insert);
	echo $insert;
	return $result;
}
if($_POST['max'] || $_POST['cols'] || $_POST['rows'] || $_POST['indexing'])
{ updateModType1($item['id']); }

$result = mysql_query("SELECT * FROM ".DB_PERFIX."mod_type_1 WHERE mod_id=".$item['id']." LIMIT 1;");
if(mysql_num_rows($result) < 1)
{addModType1($item['id']);}
else
{
	while($row = mysql_fetch_array($result))
	{
		$item['max'] = $row['max'];
		$item['cols'] = $row['cols'];
		$item['rows'] = $row['rows'];
		$item['indexing'] = $row['indexing'];
	}
}

?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td class="admin_cell" width="150">Max Elements:</td>
		<td class="admin_cell">
			<select name="max" onChange="edit_form.submit()" style="width:300">
				<option value="0" selected>No Limit</option>
				<?php 
					for ($i = 1; $i<501; $i++)
					{
						if($i == $item['max'])
						{
							echo '<option value="'.$i.'" selected>'.$i.'</option>';
						}
						else
						{
							echo '<option value="'.$i.'" >'.$i.'</option>';
						}
					}
				?>
			</select>
		</td>
		<td class="admin_cell_stat" width="150"></td>
	</tr>
	<tr>
		<td class="admin_cell" width="150">Elements in a row:</td>
		<td class="admin_cell">
			<select name="cols" onChange="edit_form.submit()" style="width:300">
				<option value="0" selected>No Limit</option>
				<?php 
					for ($i = 1; $i<51; $i++)
					{
						if($i == $item['cols'])
						{
							echo '<option value="'.$i.'" selected>'.$i.'</option>';
						}
						else
						{
							echo '<option value="'.$i.'" >'.$i.'</option>';
						}
					}
				?>
			</select>
		</td>
		<td class="admin_cell_stat" width="150"></td>
	</tr>
	<tr>
		<td class="admin_cell" width="150">Max Rows:</td>
		<td class="admin_cell">
			<select name="rows" onChange="edit_form.submit()" style="width:300">
				<option value="0" selected>No Limit</option>
				<?php 
					for ($i = 1; $i<51; $i++)
					{
						if($i == $item['rows'])
						{
							echo '<option value="'.$i.'" selected>'.$i.'</option>';
						}
						else
						{
							echo '<option value="'.$i.'" >'.$i.'</option>';
						}
					}
				?>
			</select>
		</td>
		<td class="admin_cell_stat" width="150"></td>
	</tr>
	<tr>
		<td class="admin_cell" width="150">Indexing Leftovers:</td>
		<td class="admin_cell">
			<select name="indexing" onChange="edit_form.submit()" style="width:300">
				<option value="0" <?php if ($item['indexing'] == '0'){echo 'selected'; }?> >No</option>
				<option value="1" <?php if ($item['indexing'] == '1'){echo 'selected'; }?> >Yes</option>
			</select>
		</td>
		<td class="admin_cell_stat" width="150"></td>
	</tr>
</table>